<?=$header?>

<script src="<?=base_url();?>system/scriptaculous/lib/prototype.js" type="text/javascript"></script>
<script src="<?=base_url();?>system/scriptaculous/src/scriptaculous.js" type="text/javascript"></script>
<script src="<?=base_url();?>system/scriptaculous/src/unittest.js" type="text/javascript"></script>

<script src="<?=base_url();?>system/tiny_mce/tiny_mce.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
	mode : "textareas",
	theme : "advanced",
	plugins : "table,advimage,advlink,contextmenu,paste,directionality,visualchars,nonbreaking,xhtmlxtras",
	theme_advanced_buttons1 : "cut,copy,paste,pastetext,pasteword,|,undo,redo,|,help,code",
	theme_advanced_buttons2 : "formatselect,fontselect,fontsizeselect,|,bullist,numlist,|,link,unlink,anchor,image,cleanup,|,forecolor,backcolor",
	theme_advanced_buttons3 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,hr,removeformat,|,sub,sup,|,charmap,tablecontrols",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_path_location : "bottom",
	extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
	content_css: "<?=base_url();?>system/tiny_mce/style.css"
});

function confirmation(){
	if(confirm("Are you sure you want to delete this page?")){
		window.location="<?=base_url();?>manage/delete/<?=$id?>";
	}
}
</script>

<p>
<div style="width:615px;">
<?
function mysql_to_date($date){
	//Y-m-d H:i:s
	$temp = split(' ', $date);
	$date = $temp[0];
	$time = $temp[1];
	$temp2 = explode('-', $date);
	$temp3 = explode(':', $time);
	
	//Date
	$year = $temp2[0];
	$month = $temp2[1];
	$day = $temp2[2];
	//Time
	$hour = $temp3[0];
	$minute = $temp3[1];
	$second = $temp3[2];
	return "$day/$month/$year, $hour:$minute";
}

$query = $this->db->query('SELECT * FROM gcms_posts WHERE ID='.$id);
$row = $query->row();
echo form_open('manage/edit2/'.$id);
echo '<div class="boxmeta">(created by '.$row->post_author.' on '.mysql_to_date($row->post_date).')</div><h2>Title</h2><br />';
echo '<input type="text" name="title" maxlength="500" size="50" style="width:600px;" value="'.$row->post_title.'" />';
echo '<br /><br />';
echo '<h2>Content</h2><br />';
echo '<textarea name="content" id="content" cols="90" rows="20">'.$row->post_content.'</textarea>';
echo '<br /><div class="option_box" style="width:450px;">
<a onclick="Effect.toggle(\'more_box\', \'slide\');"><h2>More Options</h2></a>
	<div id="more_box" style="display:none;"><p>';
echo 'Page Slug <span class="meta">('.base_url().'<b>'.$row->post_slug.'</b>)</span><br />';
echo form_input('slug', $row->post_slug);
echo '<br /><br />';
echo '<a onclick="confirmation()">Delete this page</a><br />';
/*echo '<br />';
echo 'Page in Main Menu?<br />';
$options = array(
                  '1'  => 'Yes',
                  '0'    => 'No',
                );
echo form_dropdown('menu', $options, $row->post_menu);
echo '<br />';
echo 'Page Order <span class="meta">(if in main menu)</span><br />';
$data = array(
	  'name'        => 'order',
	  'value'       => $row->post_order,
	  'size'        => '5'
	);
echo form_input($data);*/
echo '</p></div></div>';
echo form_submit('submit', 'Edit Page');
echo '<input type="button" value="Cancel" onclick="javascript:window.location = \''.base_url().'manage\'" />';
echo form_close();
?>
</div>
</p>

<?=$footer?>

</body>
</html>